
/**
 * @Project : Clion_ProgrammingExercises
 * @File : 2
 * @Author : WangRuoyu 
 * @Date : 2023/5/17 16:27
 */

#include "iostream"

using namespace std;

int main() {
    int n, k, t, x1, y1, x2, y2;
    scanf("%d %d %d %d %d %d %d", &n, &k, &t, &x1, &y1, &x2, &y2);
    bool st[n][t];
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < t; ++j) {
            st[i][j] = false;
        }
    }

    int a = 0;
    int b = 0;

    for (int i = 0; i < n; ++i) {
        bool flag = false;
        for (int j = 0; j < t; ++j) {
            int x, y;
            scanf("%d %d", &x, &y);
            if (x >= x1 && x <= x2 && y >= y1 && y <= y2) {
                st[i][j] = true;
                if (!flag) {
                    a++;
                    flag = true;
                }
            }
        }
    }

    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < t + 1 - k; ++j) {
            bool flag = true;
            for (int l = j; l < j + k; ++l) {
                if (!st[i][l]) {
                    flag = false;
                    break;
                }
            }
            if (flag) {
                b++;
                break;
            }
        }
    }
    cout << a << endl << b;
    return 0;
}